package com.blackrock.das.web.controllers;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;

import com.blackrock.das.web.exceptions.UnknownResourceException;

/**
 * Default controller that exists to return a proper REST response for unmapped requests.
 */
// @Controller
public class DefaultController {

    /** The Constant LOGGER. */
    private static final Logger LOGGER = LoggerFactory.getLogger(DefaultController.class);

    /**
     * Unmapped request.
     *
     * @param request the request
     */
    @RequestMapping("/**")
    public void unmappedRequest(HttpServletRequest request) {
        LOGGER.info("No dedicated controller found for url {}. Using the DefaultController instead.", request.getRequestURI());
        String uri = request.getRequestURI();
        throw new UnknownResourceException("There is no resource for path " + uri);
    }

}
